package com.yc.thread;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Test11_priority {
    public static void main(String[] args) {
        ShowTimeTask2 task2= new ShowTimeTask2();
        Thread  t= new Thread(task2);
        t.setName("线程1");
        t.start();

        Thread t2 =new Thread(task2,"线程2");
        t2.setPriority(1);
        t2.start();
    }
}
class ShowTimeTask2 implements Runnable{
    private  boolean flag;
    @Override
    public void run() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 hh:mm:ss S");
        Date d= null;
        while (true){
            d=new Date();
            System.out.println(Thread.currentThread().getName()+"输出当前时间"+sdf.format(d));
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
